package com.lg.concurrent.lock;

import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * juc的读写锁
 * 只有读读的时候是乐观锁
 * 占写的 都是悲观锁
 */
public class ReadWriteLockTest {
    public static void main(String[] args) {
        ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock();
        ReentrantReadWriteLock.WriteLock writeLock = reentrantReadWriteLock.writeLock();
        ReentrantReadWriteLock.ReadLock readLock = reentrantReadWriteLock.readLock();

        writeLock.lock();
        writeLock.unlock();
        readLock.lock();
        readLock.unlock();
    }
}
